package com.cgwx.data.dto;

import com.cgwx.auth.util.TreeUtil.TreeNode;
import com.cgwx.entity.File;
import com.cgwx.entity.FileFolder;
import com.cgwx.entity.Folder;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.sql.Timestamp;
import java.time.format.DateTimeFormatter;

@Data
@Getter
@Setter
public class NpjFileFolder extends TreeNode<NpjFileFolder>{
    private static final DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    private String entityId;

    private String entityName;

    private String entityRoom;

    private String ownerAccount;

    private String ownerName;

    private String parentId;

    private String fileId;

    private String fileUrl;

    private String versionId;

    private String type;

    private String tag;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Timestamp createTime;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Timestamp updateTime;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
    private Timestamp authUpdateTime;

    private String isFavorite;

    private String Auth;

    private float fileSize;

    private String fileNum;

    private String location;

    private String isDeleted;

    private String authorityLevel;

    private String column;

    private String sort;

    public NpjFileFolder(){

    }

    public NpjFileFolder(File file){
        this.entityId = file.getEntityId();
        this.entityName = file.getEntityName();
        this.entityRoom = file.getEntityRoom();
        this.ownerAccount = file.getOwnerAccount();
        this.ownerName = file.getOwnerName();
        this.parentId = file.getParentId();
        this.type = file.getType();
        this.tag = file.getTag();
        this.createTime = file.getCreateTime();
        this.updateTime = file.getUpdateTime();
        this.fileId = file.getFileId();
        this.fileUrl = file.getFileUrl();
        this.versionId = file.getVersionId();
        this.fileSize = file.getFileSize();
        this.isDeleted = file.getIsDeleted();
    }

    public NpjFileFolder(Folder folder){
        this.entityId = folder.getEntityId();
        this.entityName = folder.getEntityName();
        this.entityRoom = folder.getEntityRoom();
        this.ownerAccount = folder.getOwnerAccount();
        this.ownerName = folder.getOwnerName();
        this.parentId = folder.getParentId();
        this.type = folder.getType();
        this.tag = folder.getTag();
        this.createTime = folder.getCreateTime();
        this.updateTime = folder.getUpdateTime();
        this.isDeleted = folder.getIsDeleted();
    }

    public NpjFileFolder(FileFolder fileFolder){
        this.entityId = fileFolder.getEntityId();
        this.entityName = fileFolder.getEntityName();
        this.entityRoom = fileFolder.getEntityRoom();
        this.ownerAccount = fileFolder.getOwnerAccount();
        this.ownerName = fileFolder.getOwnerName();
        this.parentId = fileFolder.getParentId();
        this.fileId = fileFolder.getFileId();
        this.fileUrl = fileFolder.getFileUrl();
        this.versionId = fileFolder.getVersionId();
        this.type = fileFolder.getType();
        this.tag = fileFolder.getTag();
        this.createTime = fileFolder.getCreateTime();
        this.updateTime = fileFolder.getUpdateTime();
        this.isDeleted = fileFolder.getIsDeleted();
        this.Auth = fileFolder.getAuth();
        this.fileSize = fileFolder.getFileSize();
        this.authorityLevel = fileFolder.getAuthorityLevel();
    }

    @Override
    public String toString() {
        return "npjFileFolder{" +
                "entityId='" + entityId + '\'' +
                ", entityName='" + entityName + '\'' +
                ", entityRoom='" + entityRoom + '\'' +
                ", ownerAccount='" + ownerAccount + '\'' +
                ", ownerName='" + ownerName + '\'' +
                ", parentId='" + parentId + '\'' +
                ", fileId='" + fileId + '\'' +
                ", fileUrl='" + fileUrl + '\'' +
                ", versionId='" + versionId + '\'' +
                ", type='" + type + '\'' +
                ", tag='" + tag + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", authUpdateTime=" + authUpdateTime +
                ", isFavorite='" + isFavorite + '\'' +
                ", Auth='" + Auth + '\'' +
                ", fileSize=" + fileSize +
                ", fileNum='" + fileNum + '\'' +
                ", location='" + location + '\'' +
                ", isDeleted='" + isDeleted + '\'' +
                ", authorityLevel='" + authorityLevel + '\'' +
                ", column='" + column + '\'' +
                ", sort='" + sort + '\'' +
                '}';
    }

    @Override
    public String getPid() {
        return parentId;
    }

    @Override
    public String getUuid() {
        return entityId;
    }
}
